﻿using System.Text;
using System.Collections;
using RAP.Framework.Libary.Utils;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;

namespace RAP.Framework.Libary.DomTemplateBuilder.Handler.DictionaryActions
{
	/// <summary>
	/// 获取字典项指定属性的值的Handler
	/// </summary>
	public class GetPropertyActionHandler : DictionaryActionElementHandler
    {
        public override void DoAction( IDictionary dict,
            StringBuilder writer,
            StringBuilder actionWriter,
            object rootParamObject,
            object parentParamObject,
            ITemplateRenderContext context )
        {
			var expression = actionWriter.ToString( );
            if ( expression.IsNotNullOrEmpty( ) )
            {
				var value = dict.GetString( expression );
                writer.Append( value );
            }
        }
    }
}
